Return to start page

Core/Debug/Library Signal.j

Code

		
1			/// @author Tamino Dauth
2 library ALibraryCoreDebugSignal requires ALibraryCoreDebugMisc, AStructCoreGeneralSignal
3
4 //! runtextmacro A_SIGNAL("private", "MouseMovementSignal", "real x, real y", "x, y")
5
6 private struct Window
7 private MouseMovementSignal m_signal
8
9 //! runtextmacro A_STRUCT_DEBUG("\"Window\"")
10
11 public method signal takes nothing returns MouseMovementSignal
12 return this.m_signal
13 endmethod
14
15 public method moveMouse takes real x, real y returns nothing
16 call this.m_signal.emit(x, y)
17 endmethod
18
19 private static method privateSlot0 takes real x, real y returns nothing
20 debug call thistype.staticPrint("Private slot 0 with x " + R2S(x) + " and y " + R2S(y) + ".")
21 endmethod
22
23 private static method privateSlot1 takes real x, real y returns nothing
24 debug call thistype.staticPrint("Private slot 1 with x " + R2S(x) + " and y " + R2S(y) + ".")
25 endmethod
26
27 public static method create takes nothing returns thistype
28 local thistype this = thistype.allocate()
29 set this.m_signal = MouseMovementSignal.create()
30 call this.m_signal.connect(thistype.privateSlot0)
31 call this.m_signal.connect(thistype.privateSlot1)
32 return this
33 endmethod
34 endstruct
35
36 private function publicSlot takes real x, real y returns nothing
37 debug call Print("Public slot with x " + R2S(x) + " and y " + R2S(y) + ".")
38 endfunction
39
40 globals
41 private Window window
42 endglobals
43
44 function ASignalDebug takes nothing returns nothing
45 set window = Window.create()
46 call window.signal().connect(publicSlot)
47 debug call Print("Created window. Moving mouse to (10.0 | 15.0).")
48 call window.moveMouse(10.0, 15.0)
49 debug call Print("Finished movement.")
50 endfunction
51
52 endlibrary